<template>
	<view>
		<view class="wrap">
			<view class="u-tabs-box">
				<u-tabs-swiper ref="uTabs" :list="list" :current="current" @change="tabsChange" 
				 swiperWidth="750"></u-tabs-swiper>
			</view>
			<swiper class="swiper-box" :current="swiperCurrent" @transition="transition" @animationfinish="animationfinish">
				<swiper-item class="swiper-item" >
					<scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
						<zlfw></zlfw>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiper-item" >
					<scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
						<zfrh></zfrh>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiper-item" >
					<scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
						<mdjftj></mdjftj>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiper-item" >
					<scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
						<ldrk></ldrk>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiper-item" >
					<scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
						<cldj></cldj>
					</scroll-view>
				</swiper-item>
				<swiper-item class="swiper-item" >
					<scroll-view scroll-y class="scroll-view" @scrolltolower="onreachBottom">
						<bzcq></bzcq>
					</scroll-view>
				</swiper-item>
			</swiper>
		</view>
	</view>
</template>

<script>
	import zlfw from './xxcj/zlfw.vue'
	import zfrh from './xxcj/zfrh.vue'
	import mdjftj from './xxcj/mdjftj.vue'
	import ldrk from './xxcj/ldrk.vue'
	import cldj from './xxcj/cldj.vue'
	import bzcq from './xxcj/bzcq.vue'
	export default {
		components:{zlfw,zfrh,mdjftj,ldrk,cldj,bzcq},
		data() {
			return {
				list: [{
					id: 1,
					name: '租赁房屋'
				}, {
					id: 2,
					name: '走访入户登记'
				}, {
					id: 3,
					name: '矛盾纠纷调解'
				}, {
					id: 4,
					name: '流动人口采集'
				}, {
					id: 5,
					name: '车辆登记'
				}, {
					id: 99,
					name: '本周出勤'
				}],
				// 因为内部的滑动机制限制，请将tabs组件和swiper组件的current用不同变量赋值
				current: 0, // tabs组件的current值，表示当前活动的tab选项
				swiperCurrent: 0, // swiper组件的current值，表示当前那个swiper-item是活动的
			};
		},
		methods: {
			// tabs通知swiper切换
			tabsChange(index) {
				this.swiperCurrent = index;
			},
			// swiper-item左右移动，通知tabs的滑块跟随移动
			transition(e) {
				let dx = e.detail.dx;
				this.$refs.uTabs.setDx(dx);
			},
			// 由于swiper的内部机制问题，快速切换swiper不会触发dx的连续变化，需要在结束时重置状态
			// swiper滑动结束，分别设置tabs和swiper的状态
			animationfinish(e) {
				let current = e.detail.current;
				this.$refs.uTabs.setFinishCurrent(current);
				this.swiperCurrent = current;
				this.current = current;
			},
			// scroll-view到底部加载更多
			onreachBottom() {
				
			}
		},
		onLoad() {
			
		},  
		onUnload() {  
			// 移除监听事件  
			uni.$off('addDsr');  
		},
	};
</script>

<style lang="scss" scoped>
	.wrap {
		display: flex;
		flex-direction: column;
		height: calc(100vh - var(--window-top));
		width: 100%;
	}
	.swiper-box {
		flex: 1;
	}
	.swiper-item {
		height: 100%;
	}
	.scroll-view {
		width: 100%;
		height: 100%;
	}
</style>
